﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.Net.Sockets;
using System.IO;


namespace ClientApplication
{
    public class MessageQueue
    {
        bool on { get; set; } //Flag to toggle on/off (reset)
        int _Count; //Same count as the queues.
        public int Count  //Get set for count.
        {
            get
            {
                _Count = queue.Count;

                return _Count;
            }
            set
            {
                _Count = value;
            }

        }
        Queue<Message> queue;
        public MessageQueue()
        {
            on = false;

            queue = new Queue<Message>();
            Count = 0;
        }
        public void Enqueue(Message message)
        {
            queue.Enqueue(message);
        }
        public Message Dequeue()
        {
            return queue.Dequeue();
        }
        //Clears old queue and starts accepting messages for this type in getMessage thread.
        public void StartListen()
        {
            queue.Clear();
            on = true;
        }
        //Stops accepting messages for this type in getMessage thread.
        public void StopListen()
        {
            on = false;
        }
    }


}
